<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id ="myInput" type="text" disabled > <br>

    <input class="hobby" type="checkbox">学习 <br>
    <input class="hobby" type="checkbox">生活  <br>
    <input class="hobby" type="checkbox">远方  <br>
    <input class="hobby" type="checkbox">诗  <br>


    <select  id="basketMath">
        <option>南京队</option>
        <option>苏州队</option>
        <option>无锡队</option>
        <option>淮安队</option>
    </select>
     

    <button onclick="test()">开启禁用或者启用</button>
    <button onclick="selectAll()">全选</button>
    <button onclick="otherHand()">反选</button>


    <button onclick="selectOperator()">设置select的选中操作</button>




    <script>
        function test(){
            const myInput = document.querySelector("#myInput");
            myInput.disabled= !myInput.disabled;
        }


        function selectAll(){
            let hobbies = document.querySelectorAll(".hobby");
            for(let i = 0 ;i<hobbies.length;i++) {
                hobbies[i].checked = true;
            }
        }

        function otherHand(){
            let hobbies = document.querySelectorAll(".hobby");
            for(let i = 0 ;i<hobbies.length;i++) {
                hobbies[i].checked = !hobbies[i].checked ;
            }
        }

        function selectOperator(){
            const  basketMath = document.querySelector("#basketMath");
            basketMath[2].selected = true;
        }

    </script>


</body>
</html>